package com.joysuch.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
public class MidA implements Cloneable{

    @ExcelIgnore
    private Integer id;

    /**分辨原始数据和分配数据（非灰色工时和灰色工时），只有分配和原始两种状态*/
    @ExcelIgnore
    private String addFlag;

    @ExcelIgnore
    private String hourType2;

    /** 作为原始数据 的 数据类型（分配？原始？转嫁？其他？）*/
    @ExcelIgnore
    private String allotFlag;

    @ExcelProperty("组织")
    private String org;

    @ExcelProperty("考勤工时")
    private BigDecimal checkHour = new BigDecimal(0);

    @ExcelProperty("军队")
    private String army;

    @ExcelProperty("一级")
    private String deptOne;

    @ExcelProperty("二级/")
    private String deptTwo;

    @ExcelProperty("研发项目全称")
    private String rdProFullName;

    /** 标记数据是 得到分配，还是分配出去的，只有分配和原始两种状态*/
    @ExcelProperty("工时类型")
    private String hourType;

    @ExcelProperty("研发类型")
    private String rdType;

    @ExcelProperty(value = "分配筛选-入账表用")
    private String allotScreen;

    @ExcelProperty(value = "BU")
    private String bu;

    @ExcelProperty(value = "研发编号")
    private String rdNo;

    @ExcelProperty(value = "项目名称")
    private String proName;

    @ExcelProperty(value = "姓名", index = 14)
    private String name;

    @ExcelProperty(value = "个人工时")
    private BigDecimal personalHour;

    @ExcelProperty("占比")
    private BigDecimal proportion;

    @ExcelProperty("提成")
    private BigDecimal proBonus;

    @ExcelProperty("基本薪")
    private BigDecimal basicSalary;

    @ExcelProperty("考勤扣款")
    private BigDecimal checkDeduct;

    @ExcelProperty("其他扣款")
    private BigDecimal otherDeduct;

    @ExcelProperty(value = "本期收入")
    private BigDecimal currentIncome;

    @ExcelProperty(value = "个人社保")
    private BigDecimal personalSocialSecurity;

    @ExcelProperty(value = "个人养老")
    private BigDecimal personalProvideAged;

    @ExcelProperty(value = "个人医疗")
    private BigDecimal personalMedical;

    @ExcelProperty(value = "个人失业")
    private BigDecimal personalUnemployment;

    @ExcelProperty(value = "个人公积金")
    private BigDecimal personalAccuFunds;

    @ExcelProperty(value = "企业社保")
    private BigDecimal companySocialSecurity;

    @ExcelProperty(value = "单位养老")
    private BigDecimal conpanyProvideAged;

    @ExcelProperty(value = "单位医疗")
    private BigDecimal conpanyMedical;

    @ExcelProperty(value = "单位失业")
    private BigDecimal conpanyUnemployment;

    @ExcelProperty(value = "单位工伤")
    private BigDecimal companyInjury;

    @ExcelProperty(value = "单位生育")
    private BigDecimal companyBear;

    @ExcelProperty(value = "采暖费")
    private BigDecimal companyHeat;

    @ExcelProperty(value = "残保金")
    private BigDecimal companyDisableSecurity;

    @ExcelProperty(value = "滞纳金")
    private BigDecimal lateFees;

    @ExcelProperty(value = "企业公积金")
    private BigDecimal companyAccuFunds;

    @ExcelProperty(value = "北京额外残保")
    private BigDecimal bjAccuFunds;

    @ExcelProperty(value = "收入+公司")
    private BigDecimal incomeCompany;

    @ExcelProperty(value = "公司承担")
    private BigDecimal corporatePart;

    @ExcelProperty(value = "奖金")
    private BigDecimal bonus;

    @ExcelProperty(value = "其他扣款+考勤扣款")
    private BigDecimal otherCheckDeduction;

    public MidA calcAll(Salary hourWork) {
        BigDecimal proportion = this.getProportion();
        this.setProBonus(hourWork.getProBonus().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCheckHour(hourWork.getCheckHour().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setBasicSalary(hourWork.getBasicSalary().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCheckDeduct(hourWork.getCheckDeduct().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setOtherDeduct(hourWork.getOtherDeduct().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCurrentIncome(hourWork.getCurrentIncome().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalSocialSecurity(hourWork.getPersonalSocialSecurity().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalProvideAged(hourWork.getPersonalProvideAged().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalMedical(hourWork.getPersonalMedical().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalUnemployment(hourWork.getPersonalUnemployment().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalAccuFunds(hourWork.getPersonalAccuFunds().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanySocialSecurity(hourWork.getCompanySocialSecurity().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setConpanyProvideAged(hourWork.getConpanyProvideAged().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setConpanyMedical(hourWork.getConpanyMedical().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setConpanyUnemployment(hourWork.getConpanyUnemployment().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyInjury(hourWork.getCompanyInjury().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyBear(hourWork.getCompanyBear().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyHeat(hourWork.getCompanyHeat().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyDisableSecurity(hourWork.getCompanyDisableSecurity().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setLateFees(hourWork.getLateFees().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyAccuFunds(hourWork.getCompanyAccuFunds().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setBjAccuFunds(hourWork.getBjAccuFunds().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setIncomeCompany(hourWork.getIncomeCompany().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCorporatePart(hourWork.getCorporatePart().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setBonus(hourWork.getBonus().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setOtherCheckDeduction(hourWork.getOtherCheckDeduction().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        return this;
    }

    public MidA calcAll(MidA hourWork) {
        BigDecimal proportion = this.getProportion();
        this.setProBonus(hourWork.getProBonus().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCheckHour(hourWork.getCheckHour().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setBasicSalary(hourWork.getBasicSalary().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCheckDeduct(hourWork.getCheckDeduct().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setOtherDeduct(hourWork.getOtherDeduct().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCurrentIncome(hourWork.getCurrentIncome().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalSocialSecurity(hourWork.getPersonalSocialSecurity().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalProvideAged(hourWork.getPersonalProvideAged().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalMedical(hourWork.getPersonalMedical().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalUnemployment(hourWork.getPersonalUnemployment().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setPersonalAccuFunds(hourWork.getPersonalAccuFunds().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanySocialSecurity(hourWork.getCompanySocialSecurity().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setConpanyProvideAged(hourWork.getConpanyProvideAged().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setConpanyMedical(hourWork.getConpanyMedical().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setConpanyUnemployment(hourWork.getConpanyUnemployment().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyInjury(hourWork.getCompanyInjury().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyBear(hourWork.getCompanyBear().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyHeat(hourWork.getCompanyHeat().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyDisableSecurity(hourWork.getCompanyDisableSecurity().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setLateFees(hourWork.getLateFees().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCompanyAccuFunds(hourWork.getCompanyAccuFunds().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setBjAccuFunds(hourWork.getBjAccuFunds().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setIncomeCompany(hourWork.getIncomeCompany().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setCorporatePart(hourWork.getCorporatePart().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setBonus(hourWork.getBonus().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        this.setOtherCheckDeduction(hourWork.getOtherCheckDeduction().multiply(proportion).setScale(10, RoundingMode.HALF_UP));
        return this;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

}
